package com.yao.spider.yiyao.util;

import com.alibaba.excel.EasyExcel;
import com.yao.spider.yiyao.bean.MedicineInfoStandard;
import com.yao.spider.yiyao.bean.YaoYuanWang;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;

public class ExcelUtil {

    public static List<YaoYuanWang> readMedicineNameExcel(String path) {
        try {
            InputStream inputStream = new FileInputStream(path);
            List<YaoYuanWang> medicineNameExcelBeans = EasyExcel.read(inputStream)
                    .head(YaoYuanWang.class)
                    .sheet()
                    .headRowNumber(1)
                    .doReadSync();
            return medicineNameExcelBeans;
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        return null;
    }
    public static List<MedicineInfoStandard> readMedicineInfoStandardExcel(String path) {
        try {
            InputStream inputStream = new FileInputStream(path);
            List<MedicineInfoStandard> medicineNameExcelBeans = EasyExcel.read(inputStream)
                    .head(MedicineInfoStandard.class)
                    .sheet()
                    .headRowNumber(1)
                    .doReadSync();
            return medicineNameExcelBeans;
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        return null;
    }

    public static void main(String[] args) {

    }

}
